package com.qbw.app.module.user.activity;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.qbw.app.Constant;
import com.qbw.app.R;
import com.qbw.app.databinding.UserActivityAccountSafeBinding;
import com.qbw.app.model.UserInfo;
import com.qbw.app.module.common.activity.CommonActivity;
import com.qbw.app.module.vehicle.activity.VehicleNotificationVehicleListActivity;

/**
 * @author QBW
 * @date 2019-09-22
 */
public class UserAccountSafeActivity extends CommonActivity<UserActivityAccountSafeBinding> {

    private UserInfo mUserInfo;

    public static void startActivity(Context context, UserInfo userInfo) {
        Intent intent = new Intent(context, UserAccountSafeActivity.class);
        if (!(context instanceof Activity)) {
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        }
        intent.putExtra(Constant.KEY_USERINFO, userInfo);
        context.startActivity(intent);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.user_activity_account_safe;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bundle args = savedInstanceState == null ? getIntent().getExtras() : savedInstanceState;
        mUserInfo = (UserInfo) args.getSerializable(Constant.KEY_USERINFO);
        mBinding.title.setListener(this);
        if (mUserInfo != null) {
            mBinding.tvPhone.setText(mUserInfo.getTelCode() + " " + mUserInfo.getPhone());
        }
        mBinding.llWeixin.setOnClickListener(this);
        mBinding.llModifyPassword.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        int vid = v.getId();
        if (vid == R.id.ll_modify_password) {
            if (mUserInfo != null) {
                UserResetPasswordActivity.startActivity(this, mUserInfo);
            }
        } else if (vid == R.id.ll_weixin) {

        }
    }

    @Override
    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        outState.putSerializable(Constant.KEY_USERINFO, mUserInfo);
    }

}
